<?php

namespace App\Notifications\Channels;

use App\Services\IMobileService;
use Illuminate\Notifications\Notification;

/**
 * 短信频道
 * User: ownfi
 * Date: 2017-04-05
 * Time: 12:29
 */
class SmsChannel
{

    private $mobileService;

    public function __construct(IMobileService $mobileService)
    {
        $this->mobileService = $mobileService;
    }

    /**
     * 发送给定通知
     * @param $notifiable
     * @param Notification $notification
     */
    public function send($notifiable, Notification $notification)
    {
        list($phoneNum,$message) = $notification->toSms($notifiable);

        $this->mobileService->sendMessage($phoneNum,$message);
    }

}